#jinja2前端模板渲染语法
from flask import Flask,url_for,redirect,render_template,request

app = Flask(__name__)


@app.route('/')
def index():
    name='小李'

    #假设从数据库取得学生姓名列表
    name_list = ['小明','小红','小青']
    stu_list = [{'name':'小李','age':13,'phone':'2342'},
                {'name': '小红', 'age': 13, 'phone': '233242'},{'name':'小明','age':13,'phone':'23342'}]
    #假设从数据库里取一个字段信息包含html语法
    html_content = """
        <body>
            <h1>python</h1>
        <body>
    """
    return render_template('index.html',name=name,name_list=name_list,stu_list=stu_list,html_content=html_content)

@app.route('/about')
def about():
    return render_template( 'about.html')

if __name__ == '__main__':
    app.run(post=5002)
